using System;
using System.Collections.Generic;

namespace Chat.Backend.Models
{
    #region 聊天相关模型

    /// <summary>
    /// 聊天消息
    /// </summary>
    public class ChatMessage
    {
        /// <summary>
        /// 消息ID
        /// </summary>
        public string Id { get; set; }
        
        /// <summary>
        /// 发送者ID
        /// </summary>
        public string SenderId { get; set; }
        
        /// <summary>
        /// 接收者ID
        /// </summary>
        public string ReceiverId { get; set; }
        
        /// <summary>
        /// 消息内容
        /// </summary>
        public string Content { get; set; }
        
        /// <summary>
        /// 消息类型
        /// </summary>
        public MessageType Type { get; set; }
        
        /// <summary>
        /// 是否是群聊消息
        /// </summary>
        public bool IsGroupChat { get; set; }
        
        /// <summary>
        /// 发送时间
        /// </summary>
        public DateTime SendTime { get; set; }
        
        /// <summary>
        /// 接收时间
        /// </summary>
        public DateTime? ReceiveTime { get; set; }
        
        /// <summary>
        /// 消息状态
        /// </summary>
        public MessageStatus Status { get; set; }
        
        /// <summary>
        /// 语音或视频消息的时长（秒）
        /// </summary>
        public int? Duration { get; set; }
        
        /// <summary>
        /// 附加属性
        /// </summary>
        public Dictionary<string, string> Attributes { get; set; }
    }

    /// <summary>
    /// 消息状态
    /// </summary>
    public enum MessageStatus
    {
        /// <summary>
        /// 发送中
        /// </summary>
        Sending,
        
        /// <summary>
        /// 已发送
        /// </summary>
        Sent,
        
        /// <summary>
        /// 已送达
        /// </summary>
        Delivered,
        
        /// <summary>
        /// 已读
        /// </summary>
        Read,
        
        /// <summary>
        /// 发送失败
        /// </summary>
        Failed,
        
        /// <summary>
        /// 已接收
        /// </summary>
        Received
    }

    /// <summary>
    /// 消息类型
    /// </summary>
    public enum MessageType
    {
        /// <summary>
        /// 文本消息
        /// </summary>
        Text,
        
        /// <summary>
        /// 图片消息
        /// </summary>
        Image,
        
        /// <summary>
        /// 语音消息
        /// </summary>
        Voice,
        
        /// <summary>
        /// 视频消息
        /// </summary>
        Video,
        
        /// <summary>
        /// 位置消息
        /// </summary>
        Location,
        
        /// <summary>
        /// 文件消息
        /// </summary>
        File,
        
        /// <summary>
        /// 系统消息
        /// </summary>
        System,
        
        /// <summary>
        /// 未知类型
        /// </summary>
        Unknown
    }

    /// <summary>
    /// 聊天消息请求结果
    /// </summary>
    public class MessageResult
    {
        /// <summary>
        /// 是否成功
        /// </summary>
        public bool Success { get; set; }
        
        /// <summary>
        /// 消息ID
        /// </summary>
        public string MessageId { get; set; }
        
        /// <summary>
        /// 错误信息
        /// </summary>
        public string Error { get; set; }
    }

    /// <summary>
    /// 聊天消息体
    /// </summary>
    public class ChatMessageBody
    {
        /// <summary>
        /// 消息ID
        /// </summary>
        public string MessageId { get; set; }
        
        /// <summary>
        /// 消息类型
        /// </summary>
        public string Type { get; set; }
        
        /// <summary>
        /// 消息内容
        /// </summary>
        public string Content { get; set; }
        
        /// <summary>
        /// 时间戳
        /// </summary>
        public long Timestamp { get; set; }
        
        /// <summary>
        /// 语音时长
        /// </summary>
        public int? Duration { get; set; }
    }

       /// <summary>
    /// 消息回执体
    /// </summary>
    public class ChatMessageReceiptBody
    {
        /// <summary>
        /// 消息ID
        /// </summary>
        public string MessageId { get; set; }
        
        /// <summary>
        /// 状态
        /// </summary>
        public string Status { get; set; }
        
        /// <summary>
        /// 时间戳
        /// </summary>
        public long Timestamp { get; set; }
    }

    /// <summary>
    /// 位置信息
    /// </summary>
    public class LocationInfo
    {
        /// <summary>
        /// 纬度
        /// </summary>
        public double Latitude { get; set; }
        
        /// <summary>
        /// 经度
        /// </summary>
        public double Longitude { get; set; }
        
        /// <summary>
        /// 地址
        /// </summary>
        public string Address { get; set; }
    }

    /// <summary>
    /// 群聊
    /// </summary>
    public class GroupChat
    {
        /// <summary>
        /// 群聊ID
        /// </summary>
        public string Id { get; set; }
        
        /// <summary>
        /// 群聊名称
        /// </summary>
        public string Name { get; set; }
        
        /// <summary>
        /// 群主ID
        /// </summary>
        public string CreatorId { get; set; }
        
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }
        
        /// <summary>
        /// 群公告
        /// </summary>
        public string Announcement { get; set; }
        
        /// <summary>
        /// 群头像URL
        /// </summary>
        public string AvatarUrl { get; set; }
        
        /// <summary>
        /// 群成员
        /// </summary>
        public List<GroupChatMember> Members { get; set; }
    }

    /// <summary>
    /// 群聊成员
    /// </summary>
    public class GroupChatMember
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        public string UserId { get; set; }
        
        /// <summary>
        /// 用户在群中的角色
        /// </summary>
        public GroupChatRole Role { get; set; }
        
        /// <summary>
        /// 加入时间
        /// </summary>
        public DateTime JoinTime { get; set; }
        
        /// <summary>
        /// 群昵称
        /// </summary>
        public string Nickname { get; set; }
    }

    /// <summary>
    /// 群聊角色
    /// </summary>
    public enum GroupChatRole
    {
        /// <summary>
        /// 群主
        /// </summary>
        Owner,
        
        /// <summary>
        /// 管理员
        /// </summary>
        Admin,
        
        /// <summary>
        /// 普通成员
        /// </summary>
        Member
    }

    /// <summary>
    /// 群聊创建结果
    /// </summary>
    public class GroupChatResult
    {
        /// <summary>
        /// 是否成功
        /// </summary>
        public bool Success { get; set; }
        
        /// <summary>
        /// 群聊ID
        /// </summary>
        public string GroupId { get; set; }
        
        /// <summary>
        /// 错误信息
        /// </summary>
        public string Error { get; set; }
    }

    #endregion

    #region 通话相关模型

    /// <summary>
    /// 通话会话
    /// </summary>
    public class CallSession
    {
        /// <summary>
        /// 通话ID
        /// </summary>
        public string CallId { get; set; }
        
        /// <summary>
        /// 主叫方ID
        /// </summary>
        public string CallerId { get; set; }
        
        /// <summary>
        /// 被叫方ID
        /// </summary>
        public string CalleeId { get; set; }
        
        /// <summary>
        /// 通话类型
        /// </summary>
        public CallType CallType { get; set; }
        
        /// <summary>
        /// 通话状态
        /// </summary>
        public CallStatus Status { get; set; }
        
        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime StartTime { get; set; }
        
        /// <summary>
        /// 接听时间
        /// </summary>
        public DateTime? AcceptTime { get; set; }
        
        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime? EndTime { get; set; }
    }

    /// <summary>
    /// 通话历史记录
    /// </summary>
    public class CallHistory
    {
        /// <summary>
        /// 通话ID
        /// </summary>
        public string CallId { get; set; }
        
        /// <summary>
        /// 主叫方ID
        /// </summary>
        public string CallerId { get; set; }
        
        /// <summary>
        /// 被叫方ID
        /// </summary>
        public string CalleeId { get; set; }
        
        /// <summary>
        /// 通话类型
        /// </summary>
        public CallType CallType { get; set; }
        
        /// <summary>
        /// 通话状态
        /// </summary>
        public CallStatus Status { get; set; }
        
        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime StartTime { get; set; }
        
        /// <summary>
        /// 接听时间
        /// </summary>
        public DateTime? AcceptTime { get; set; }
        
        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime EndTime { get; set; }
        
        /// <summary>
        /// 通话时长（秒）
        /// </summary>
        public int Duration { get; set; }
    }

    /// <summary>
    /// 通话类型
    /// </summary>
    public enum CallType
    {
        /// <summary>
        /// 语音通话
        /// </summary>
        Audio,
        
        /// <summary>
        /// 视频通话
        /// </summary>
        Video
    }

    /// <summary>
    /// 通话状态
    /// </summary>
    public enum CallStatus
    {
        /// <summary>
        /// 振铃中
        /// </summary>
        Ringing,
        
        /// <summary>
        /// 已接听
        /// </summary>
        Accepted,
        
        /// <summary>
        /// 已拒绝
        /// </summary>
        Rejected,
        
        /// <summary>
        /// 已结束
        /// </summary>
        Ended,
        
        /// <summary>
        /// 未接听
        /// </summary>
        Missed
    }

    /// <summary>
    /// 通话结果
    /// </summary>
    public class CallResult
    {
        /// <summary>
        /// 是否成功
        /// </summary>
        public bool Success { get; set; }
        
        /// <summary>
        /// 通话ID
        /// </summary>
        public string CallId { get; set; }
        
        /// <summary>
        /// 错误信息
        /// </summary>
        public string Error { get; set; }
    }

    /// <summary>
    /// 通话信令消息
    /// </summary>
    public class CallSignalingMessage
    {
        /// <summary>
        /// 消息类型
        /// </summary>
        public string Type { get; set; }
        
        /// <summary>
        /// 通话ID
        /// </summary>
        public string CallId { get; set; }
        
        /// <summary>
        /// 主叫方ID
        /// </summary>
        public string CallerId { get; set; }
        
        /// <summary>
        /// 主叫方名称
        /// </summary>
        public string CallerName { get; set; }
        
        /// <summary>
        /// 被叫方ID
        /// </summary>
        public string CalleeId { get; set; }
        
        /// <summary>
        /// 用户ID（用于hangup等消息）
        /// </summary>
        public string UserId { get; set; }
        
        /// <summary>
        /// 通话类型
        /// </summary>
        public string CallType { get; set; }
        
        /// <summary>
        /// SDP提议
        /// </summary>
        public string SdpOffer { get; set; }
        
        /// <summary>
        /// SDP应答
        /// </summary>
        public string SdpAnswer { get; set; }
        
        /// <summary>
        /// ICE候选
        /// </summary>
        public string IceCandidate { get; set; }
        
        /// <summary>
        /// ICE服务器列表
        /// </summary>
        public List<IceServer> IceServers { get; set; }
        
        /// <summary>
        /// 时间戳
        /// </summary>
        public long Timestamp { get; set; }
    }

    /// <summary>
    /// ICE服务器配置
    /// </summary>
    public class IceServer
    {
        /// <summary>
        /// 服务器URL
        /// </summary>
        public List<string> Urls { get; set; }
        
        /// <summary>
        /// 用户名
        /// </summary>
        public string Username { get; set; }
        
        /// <summary>
        /// 密码凭证
        /// </summary>
        public string Credential { get; set; }
    }

    #endregion

    #region 位置相关模型

    /// <summary>
    /// 用户位置
    /// </summary>
    public class UserLocation
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        public string UserId { get; set; }
        
        /// <summary>
        /// 纬度
        /// </summary>
        public double Latitude { get; set; }
        
        /// <summary>
        /// 经度
        /// </summary>
        public double Longitude { get; set; }
        
        /// <summary>
        /// 完整地址
        /// </summary>
        public string Address { get; set; }
        
        /// <summary>
        /// 国家
        /// </summary>
        public string Country { get; set; }
        
        /// <summary>
        /// 省/州
        /// </summary>
        public string Province { get; set; }
        
        /// <summary>
        /// 城市
        /// </summary>
        public string City { get; set; }
        
        /// <summary>
        /// 区/县
        /// </summary>
        public string District { get; set; }
        
        /// <summary>
        /// 街道
        /// </summary>
        public string Street { get; set; }
        
        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdateTime { get; set; }
    }

    /// <summary>
    /// 位置详情
    /// </summary>
    public class LocationDetails
    {
        /// <summary>
        /// 纬度
        /// </summary>
        public double Latitude { get; set; }
        
        /// <summary>
        /// 经度
        /// </summary>
        public double Longitude { get; set; }
        
        /// <summary>
        /// 完整地址
        /// </summary>
        public string Address { get; set; }
        
        /// <summary>
        /// 国家
        /// </summary>
        public string Country { get; set; }
        
        /// <summary>
        /// 省/州
        /// </summary>
        public string Province { get; set; }
        
        /// <summary>
        /// 城市
        /// </summary>
        public string City { get; set; }
        
        /// <summary>
        /// 区/县
        /// </summary>
        public string District { get; set; }
        
        /// <summary>
        /// 街道
        /// </summary>
        public string Street { get; set; }
    }

    /// <summary>
    /// 附近用户
    /// </summary>
    public class NearbyUser
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        public string UserId { get; set; }
        
        /// <summary>
        /// 用户昵称
        /// </summary>
        public string Nickname { get; set; }
        
        /// <summary>
        /// 头像URL
        /// </summary>
        public string AvatarUrl { get; set; }
        
        /// <summary>
        /// 距离（米）
        /// </summary>
        public double Distance { get; set; }
        
        /// <summary>
        /// 位置信息
        /// </summary>
        public UserLocation Location { get; set; }
    }

    /// <summary>
    /// Google地理编码响应
    /// </summary>
    public class GoogleGeocodingResponse
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public string Status { get; set; }
        
        /// <summary>
        /// 结果列表
        /// </summary>
        public List<GoogleGeocodingResult> Results { get; set; }
    }

    /// <summary>
    /// Google地理编码结果
    /// </summary>
    public class GoogleGeocodingResult
    {
        /// <summary>
        /// 格式化地址
        /// </summary>
        public string FormattedAddress { get; set; }
        
        /// <summary>
        /// 地址组件
        /// </summary>
        public List<GoogleAddressComponent> AddressComponents { get; set; }
    }

    /// <summary>
    /// Google地址组件
    /// </summary>
    public class GoogleAddressComponent
    {
        /// <summary>
        /// 长名称
        /// </summary>
        public string LongName { get; set; }
        
        /// <summary>
        /// 短名称
        /// </summary>
        public string ShortName { get; set; }
        
        /// <summary>
        /// 类型列表
        /// </summary>
        public List<string> Types { get; set; }
    }

    #endregion

    #region 推送相关模型

    /// <summary>
    /// 用户设备
    /// </summary>
    public class UserDevice
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        public string UserId { get; set; }
        
        /// <summary>
        /// 设备ID
        /// </summary>
        public string DeviceId { get; set; }
        
        /// <summary>
        /// 推送令牌
        /// </summary>
        public string PushToken { get; set; }
        
        /// <summary>
        /// 推送提供商
        /// </summary>
        public string PushProvider { get; set; }
        
        /// <summary>
        /// 设备型号
        /// </summary>
        public string DeviceModel { get; set; }
        
        /// <summary>
        /// 最后活跃时间
        /// </summary>
        public DateTime LastActiveTime { get; set; }
    }

    /// <summary>
    /// 推送请求
    /// </summary>
    public class PushRequest
    {
        /// <summary>
        /// 设备令牌
        /// </summary>
        public string Token { get; set; }
        
        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }
        
        /// <summary>
        /// 内容
        /// </summary>
        public string Body { get; set; }
        
        /// <summary>
        /// 数据载荷
        /// </summary>
        public Dictionary<string, string> Data { get; set; }
        
        /// <summary>
        /// 优先级
        /// </summary>
        public PushPriority Priority { get; set; }
        
        /// <summary>
        /// 声音
        /// </summary>
        public string Sound { get; set; }
        
        /// <summary>
        /// 角标数
        /// </summary>
        public int? Badge { get; set; }
        
        /// <summary>
        /// 存活时间（秒）
        /// </summary>
        public int TimeToLive { get; set; }
        
        /// <summary>
        /// 是否允许修改内容（iOS）
        /// </summary>
        public bool MutableContent { get; set; }
        
        /// <summary>
        /// 通知类别（iOS）
        /// </summary>
        public string Category { get; set; }
    }

    /// <summary>
    /// 推送优先级
    /// </summary>
    public enum PushPriority
    {
        /// <summary>
        /// 高优先级
        /// </summary>
        High,
        
        /// <summary>
        /// 普通优先级
        /// </summary>
        Normal
    }

    #endregion

    #region 事件相关模型

    /// <summary>
    /// 消息接收事件
    /// </summary>
    public class MessageReceivedEvent
    {
        /// <summary>
        /// 消息对象
        /// </summary>
        public ChatMessage Message { get; set; }
    }

    /// <summary>
    /// 推送通知事件
    /// </summary>
    public class PushNotificationEvent
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        public string UserId { get; set; }
        
        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }
        
        /// <summary>
        /// 内容
        /// </summary>
        public string Body { get; set; }
        
        /// <summary>
        /// 数据载荷
        /// </summary>
        public Dictionary<string, string> Data { get; set; }
    }

    /// <summary>
    /// XMPP连接事件
    /// </summary>
    public class XmppConnectedEvent
    {
        /// <summary>
        /// 是否已连接
        /// </summary>
        public bool Connected { get; set; }
        
        /// <summary>
        /// 时间戳
        /// </summary>
        public string Timestamp { get; set; }
        
        /// <summary>
        /// 错误信息
        /// </summary>
        public string Error { get; set; }
    }

    /// <summary>
    /// XMPP认证事件
    /// </summary>
    public class XmppAuthenticatedEvent
    {
        /// <summary>
        /// 用户名
        /// </summary>
        public string Username { get; set; }
        
        /// <summary>
        /// 是否已认证
        /// </summary>
        public bool Authenticated { get; set; }
        
        /// <summary>
        /// 错误信息
        /// </summary>
        public string Error { get; set; }
    }

    /// <summary>
    /// XMPP状态变化事件
    /// </summary>
    public class XmppStateChangedEvent
    {
        /// <summary>
        /// 状态
        /// </summary>
        public string State { get; set; }
    }

    /// <summary>
    /// XMPP消息接收事件
    /// </summary>
    public class XmppMessageReceivedEvent
    {
        /// <summary>
        /// 发送者JID
        /// </summary>
        public string From { get; set; }
        
        /// <summary>
        /// 接收者JID
        /// </summary>
        public string To { get; set; }
        
        /// <summary>
        /// 消息体
        /// </summary>
        public string Body { get; set; }
        
        /// <summary>
        /// 消息类型
        /// </summary>
        public string Type { get; set; }
        
        /// <summary>
        /// 消息ID
        /// </summary>
        public string Id { get; set; }
    }

    /// <summary>
    /// 通话请求接收事件
    /// </summary>
    public class CallOfferReceivedEvent
    {
        /// <summary>
        /// 通话ID
        /// </summary>
        public string CallId { get; set; }
        
        /// <summary>
        /// 主叫方ID
        /// </summary>
        public string CallerId { get; set; }
        
        /// <summary>
        /// 主叫方名称
        /// </summary>
        public string CallerName { get; set; }
        
        /// <summary>
        /// 通话类型
        /// </summary>
        public CallType CallType { get; set; }
        
        /// <summary>
        /// ICE服务器列表
        /// </summary>
        public List<IceServer> IceServers { get; set; }
    }

    /// <summary>
    /// 通话接受事件
    /// </summary>
    public class CallAcceptedEvent
    {
        /// <summary>
        /// 通话ID
        /// </summary>
        public string CallId { get; set; }
        
        /// <summary>
        /// 被叫方ID
        /// </summary>
        public string CalleeId { get; set; }
    }

    /// <summary>
    /// 通话拒绝事件
    /// </summary>
    public class CallRejectedEvent
    {
        /// <summary>
        /// 通话ID
        /// </summary>
        public string CallId { get; set; }
        
        /// <summary>
        /// 被叫方ID
        /// </summary>
        public string CalleeId { get; set; }
    }

    /// <summary>
    /// 通话挂断事件
    /// </summary>
    public class CallHangupEvent
    {
        /// <summary>
        /// 通话ID
        /// </summary>
        public string CallId { get; set; }
        
        /// <summary>
        /// 用户ID
        /// </summary>
        public string UserId { get; set; }
    }

    /// <summary>
    /// SDP提议接收事件
    /// </summary>
    public class SdpOfferReceivedEvent
    {
        /// <summary>
        /// 通话ID
        /// </summary>
        public string CallId { get; set; }
        
        /// <summary>
        /// 用户ID
        /// </summary>
        public string UserId { get; set; }
        
        /// <summary>
        /// SDP提议
        /// </summary>
        public string SdpOffer { get; set; }
    }

    /// <summary>
    /// SDP应答接收事件
    /// </summary>
    public class SdpAnswerReceivedEvent
    {
        /// <summary>
        /// 通话ID
        /// </summary>
        public string CallId { get; set; }
        
        /// <summary>
        /// 用户ID
        /// </summary>
        public string UserId { get; set; }
        
        /// <summary>
        /// SDP应答
        /// </summary>
        public string SdpAnswer { get; set; }
    }

    /// <summary>
    /// ICE候选接收事件
    /// </summary>
    public class IceCandidateReceivedEvent
    {
        /// <summary>
        /// 通话ID
        /// </summary>
        public string CallId { get; set; }
        
        /// <summary>
        /// 用户ID
        /// </summary>
        public string UserId { get; set; }
        
        /// <summary>
        /// ICE候选
        /// </summary>
        public string IceCandidate { get; set; }
    }

    #endregion
}
